package com.sn.author.common.enums;

import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * @Author xiaom
 * @Date 2020/9/21 13:53
 * @Version 1.0.0
 * @Description < 0(执行中) 10(成功) -10(失败)>
 **/
public enum JobEnums {
    WORKING(0,"执行中"),
    SUCCESS(10,"成功"),
    FAILED(-10,"失败");

    @Getter
    private Integer code;

    @Getter
    private String desc;

    JobEnums(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static Optional<JobEnums> match(Integer type) {
        return Arrays.stream(JobEnums.values())
                .filter(t -> t.getCode().equals(type))
                .findFirst();
    }
}
